package hit.example.Menu;

import hit.example.delegate.IOnMenuClosed;
import hit.example.hitdict.R;
import hit.example.home.HomeActivity;
import hit.example.home.RecentFabvoriteFm;
import hit.example.home.SearchVietAnhFm;
import hit.example.home.TabId;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Toast;

import com.telpoo.frame.delegate.Idelegate;

public class ViewMenu extends Activity implements IOnMenuClosed,
		OnClickListener {
	Context context;
	Idelegate idelegate;
	View v;
	TextView Tudatra;
	View menuTudatra, menuTuYeuThich,menuSearchVA;

	public ViewMenu(Context context1, Idelegate idelegate1) {
		this.context = context1;
		this.idelegate = idelegate1;

		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		v = inflater.inflate(R.layout.layout_menu, null);
		// khai bao view o day
		menuTudatra = v.findViewById(R.id.menuRecentWord);
		menuTuYeuThich = v.findViewById(R.id.menuFavoriteWord);
		menuSearchVA=v.findViewById(R.id.menuSearchVA);
		((HomeActivity) context1).setDelegateOnMenuClosed(this);// dong menu va
																// ve home
		menuTudatra.setOnClickListener(this);
		menuTuYeuThich.setOnClickListener(this);
		menuSearchVA.setOnClickListener(this);

	}

	public View getView() {

		return v;
	}

	@Override
	public void onMenuClosed() {

	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.menuRecentWord:

			HomeActivity.getInstance().pushFragments(TabId.home,
					RecentFabvoriteFm.getInstance(0), true, null);
			HomeActivity.getInstance().toggle();
			break;

		case R.id.menuFavoriteWord:
			HomeActivity.getInstance().pushFragments(TabId.home,
					RecentFabvoriteFm.getInstance(1), true, null);
			HomeActivity.getInstance().toggle();
			break;
		case R.id.menuSearchVA:
			HomeActivity.getInstance().pushFragments(TabId.home,
					SearchVietAnhFm.getInstance(), true, null);
			HomeActivity.getInstance().toggle();
			break;

		}

	}

}
